﻿// JScript ファイル

 /*┗◎◎┛=====================================================================
 *
 *【画面名】
 *      編集画面
 *
 *【概要】
 *?     検索候補値画面
 *      em_fn     ： EntityManagerフール名
 *      obj     　：ボタンID
 *
 *      hidLandId必要です、検索候補値画面表示用
 *【変更履歴】
 *┗◎◎┛====================================================================*/
function show_point(em_fn,obj)
{
    point_show(em_fn,obj,'');
}
function show_point(em_fn,obj,actionType,actionParam)
{
    point_show(em_fn,obj,'',actionType,actionParam);
}
 /*┗◎◎┛=====================================================================
 *
 *【画面名】
 *      編集画面
 *
 *【概要】
 *?     検索候補値画面
 *      em_fn     ： EntityManagerフール名
 *      obj     　：ボタンID
 *　　　_all　　　：_all　XXX_all使用
 *
 *      hidLandId必要です、検索候補値画面表示用
 *【変更履歴】
 *┗◎◎┛====================================================================*/
function point_show(em_fn,obj,_all)
{
    alert(obj.parentNode.innerHTML);
    var hid = obj.parentNode.childNodes[0];
    var txt = obj.parentNode.childNodes[1];
   
    var hid_point = hid_name.substr(0,hid_name.indexOf("__"));
    var targaet_name = hid_point.split('hid_')[1];
    var target_objid = hid_name;
    
    var tr = obj.parentNode.parentNode;
    for(var i=0;i<tr.childNodes.length;i++)
    {
        var obj_hid = tr.childNodes[i].childNodes[0];
        if(obj_hid.type == "hidden" && obj_hid.name.indexOf(hid_point) == 0)
        {
            var obj_t = tr.childNodes[i].childNodes[1];
            target_objid = target_objid + "," + obj_t.id;
            targaet_name = targaet_name + "," + obj_t.name.split('txt_')[1];
        }
    }
    //page url
    var url = "../../main/comm/EditPointList.aspx";
    
    //lang,EntityManager
    if(document.getElementById("hidLandId") == null)
    {
        url = url + "?EM_FN=" + em_fn;
    }
    else
    {
        url = url + "?lang_id=" + document.getElementById("hidLandId").value;
        url = url + "&EM_FN=" + em_fn;
    }
    
    //cur obj
    url = url + "&CUR_NAME=" + txt_name.split('txt_')[1];
    
    //targaet name
    url = url + "&TARGET_NAME=" + targaet_name;
    
    //targaet boj
    url = url + "&TARGET_OBJ=" + target_objid;
    
    //all
    url = url + "&ALL=" + _all;
    
    var wndEdCandidate = window.open(url, 'wndEdCandidate', 'width=410,height=520,resizable=yes,scrollbars=no,status=yes');
    wndEdCandidate.focus();
    
}
function point_show(em_fn,obj,_all,actionType,actionParam)
{
    var hid = obj.parentNode.childNodes[0];
    var hid_name = hid.name;
    
    if (em_fn == "csoftech.accReplace" && (hid_name.indexOf("acc_code") >= 0 || hid_name.indexOf("acc_name") >= 0)) {
        wndEdCandidate = window.open("../../main/csoftech/AccessorySelect.aspx?accMagrFlg=1&TARGET_OBJ=" + hid.id, 'wndEdCandidate', 'width=880,height=540,resizable=yes,scrollbars=yes,status=yes');
        wndEdCandidate.focus();
        return;
    }
    
    var txt = obj.parentNode.childNodes[1]
    var txt_name = txt.name;
    
    var hid_point = hid_name.substr(0,hid_name.indexOf("__"));
    var targaet_name = hid_point.split('hid_')[1];
    var target_objid = hid_name;
    
    var tr = obj.parentNode.parentNode;
    for(var i=0;i<tr.childNodes.length;i++)
    {
        var obj_hid = tr.childNodes[i].childNodes[0];
        if(obj_hid && obj_hid.type == "hidden" && obj_hid.name.indexOf(hid_point) == 0)
        {
            var obj_t = tr.childNodes[i].childNodes[1];
            target_objid = target_objid + "," + obj_t.id;
            targaet_name = targaet_name + "," + obj_t.name.split('txt_')[1];
        }
    }
    
    //page url
    var url = "../../main/comm/EditPointList.aspx";
    if (em_fn == "csoftech.storeSelect")
    {
        url = "../../main/csoftech/StoreSelect.aspx";
    }
    else if (em_fn == "csoftech.userSelect")
    {
        url = "../../main/csoftech/UserSelect.aspx";
    }
    
    //lang,EntityManager
    if(document.getElementById("hidLandId") == null)
    {
        url = url + "?EM_FN=" + em_fn;
    }
    else
    {
        url = url + "?lang_id=" + document.getElementById("hidLandId").value;
        url = url + "&EM_FN=" + em_fn;
    }
    
    //cur obj
    url = url + "&CUR_NAME=" + txt_name.split('txt_')[1];
    
    //targaet name
    url = url + "&TARGET_NAME=" + targaet_name;
    
    //targaet boj
    url = url + "&TARGET_OBJ=" + target_objid;
    
    //all
    url = url + "&ALL=" + _all;
    
    //actiontype
    if (em_fn == "csoftech.userSelect")
    {
        url = url + "&ACT=" + actionType;
    }
    //actionParam
    if (em_fn == "csoftech.storeSelect" || em_fn == "csoftech.userSelect")
    {
        url = url + "&PARAM=" + actionParam;
    }
    var wndEdCandidate;
    if (em_fn == "csoftech.storeSelect")
    {
        wndEdCandidate = window.open(url, 'wndEdCandidate', 'width=910,height=540,resizable=yes,scrollbars=yes,status=yes');
    }    
    else if (em_fn == "csoftech.userSelect")
    {
        wndEdCandidate = window.open(url, 'wndEdCandidate', 'width=610,height=540,resizable=yes,scrollbars=yes,status=yes');
    }
    else
    {
        wndEdCandidate = window.open(url, 'wndEdCandidate', 'width=410,height=540,resizable=yes,scrollbars=yes,status=yes');
    }
    wndEdCandidate.focus();
    
}
 /*┗◎◎┛=====================================================================
 *
 *【画面名】
 *      編集画面
 *
 *【概要】
 *?     検索候補値画面
 *      em_fn     ： EntityManagerフール名
 *      index     ：タイトルのカラムINDEX
 *
 *      hidLandId必要です、検索候補値画面表示用
 *【変更履歴】
 *┗◎◎┛====================================================================*/
function show_point_all(em_fn,index)
{
    var meisaitable = document.getElementById("dgmeisai");
    if(meisaitable == null) return;
    
    try
    {
        var tr = meisaitable.rows[0];
        var obj = tr.childNodes[index].childNodes[1];
        point_show(em_fn,obj,"_all");
    }
    catch(e)
    {
    }
}

 /*┗◎◎┛=====================================================================
 *
 *【画面名】
 *      編集画面
 *
 *【概要】
 *?     検索候補値画面
 *      em_fn     ： EntityManagerフール名
 *      index     ：タイトルのカラムINDEX
 *
 *      hidLandId必要です、検索候補値画面表示用
 *【変更履歴】
 *┗◎◎┛====================================================================*/
function show_input_all(em_fn,index)
{
    var meisaitable = document.getElementById("dgmeisai");
    if(meisaitable == null) return;
    
    try
    {
        var tr = meisaitable.rows[0];
        var obj = tr.childNodes[index].childNodes[2];
        point_show(em_fn,obj,"_all");
    }
    catch(e)
    {
    }
}
 /*┗◎◎┛=====================================================================
 *
 *【画面名】
 *      POINT候補値画面
 *
 *【概要】
 *?     POINT値設定
 *      strValue     ： Values(,)
 *
 *      targetIds必要です、元画面ObjID
 *【変更履歴】
 *┗◎◎┛====================================================================*/
function set_openerValue(strValue)
{
    //lang,EntityManager
    if(document.getElementById("targetIds") == null)
    {
        window.close();
        return;
    }
    else if(document.getElementById("targetIds").value == "")
    {
        window.close();
        return;
    }
    
    var strid = document.getElementById("targetIds").value;
    var ids = strid.split(',');
    var values = strValue.split(',');
    
    //value
    for(var i=1;i<ids.length;i++)
    {
        try
        {
            var targetTxt = window.opener.document.getElementById(ids[i]);
            
            targetTxt.parentNode.childNodes[0].value = values[0];
            targetTxt.value = values[i];
        } 
        catch(e)
        {}
    }
    
    window.close();
}
function set_openerValue(strValue,strDisp)
{
    //lang,EntityManager
    if(document.getElementById("targetIds") == null)
    {
        window.close();
        return;
    }
    else if(document.getElementById("targetIds").value == "")
    {
        window.close();
        return;
    }
    
    var strid = document.getElementById("targetIds").value;
    var ids = strid.split(',');
    var values = strValue.split(',');
    var disps = strDisp.split(',');
    
    //value
    for(var i=1;i<ids.length;i++)
    {
        try
        {
            var targetTxt = window.opener.document.getElementById(ids[i]);
            targetTxt.parentNode.childNodes[0].value = values[0];
            targetTxt.value = disps[i];
            targetTxt.parentNode.childNodes[3].value = values[i];
        } 
        catch(e)
        {}
    }
    
    window.close();
}

function set_opener_selectValue(strValue,strDisp)
{
    //lang,EntityManager
    if(document.getElementById("targetIds") == null)
    {
        window.close();
        return;
    }
    else if(document.getElementById("targetIds").value == "")
    {
        window.close();
        return;
    }
    var strid = document.getElementById("targetIds").value;
    var ids = strid.split(',');
    var values = strValue.split(',');
    var disps = strDisp.split(',');
    for(var i=1;i<ids.length;i++)
    {
        try
        {
            var targetTxt = window.opener.document.getElementById(ids[i]);
            if (targetTxt != null)
            {
                targetTxt.parentNode.childNodes[0].value = values[0];
                targetTxt.value = disps[i];
                targetTxt.parentNode.childNodes[2].value = values[i];
            }
        } 
        catch(e)
        {}
    }
    
    window.close();
}

 /*┗◎◎┛=====================================================================
 *
 *【画面名】
 *      POINT候補値画面
 *
 *【概要】
 *?     チェックされている行のPOINT値設定
 *      strValue     ： Values(,)
 *
 *      targetIds必要です、元画面ObjID
 *【変更履歴】
 *┗◎◎┛====================================================================*/
function set_openerValue_all(strValue)
{
    //lang,EntityManager
    if(document.getElementById("targetIds") == null)
    {
        window.close();
        return;
    }
    else if(document.getElementById("targetIds").value == "")
    {
        window.close();
        return;
    }
    
    var meisaitable = window.opener.document.getElementById("dgmeisai");
    if(meisaitable == null) return;
    
    try
    {
        var tr = meisaitable.rows[0];
                
        var strid = document.getElementById("targetIds").value;
        var ids = strid.split(',');
        var values = strValue.split(',');
        var indexs = new Array(ids.length);
        //value
        indexs[0] = 0;
        for(var i=1;i<ids.length;i++)
        {
            try
            {
                for(var j=0;j<tr.childNodes.length;j++)
                {
                    if(tr.childNodes[j].childNodes.length >= 3 
                        && tr.childNodes[j].childNodes[1].id == ids[i])
                    {
                        indexs[i] = j;
                        break;
                    }
                }
            } 
            catch(e)
            {}
        }
        
        for(var row=0; row < meisaitable.rows.length; row++){
            tr = meisaitable.rows[row];
            if(tr.childNodes[0].childNodes[0].checked)
            {
                for(var i=1;i<ids.length;i++)
                { 
                    tr.childNodes[indexs[i]].childNodes[0].value = values[0];
                    tr.childNodes[indexs[i]].childNodes[1].value = values[i];
                }                
            }            
        }
    }
    catch(e)
    {
    }
    
    window.close();
}
function set_openerValue_all(strValue,strDisp)
{
    //lang,EntityManager
    if(document.getElementById("targetIds") == null)
    {
        window.close();
        return;
    }
    else if(document.getElementById("targetIds").value == "")
    {
        window.close();
        return;
    }
    
    var meisaitable = window.opener.document.getElementById("dgmeisai");
    if(meisaitable == null) return;
    
    try
    {
        var tr = meisaitable.rows[0];
                
        var strid = document.getElementById("targetIds").value;
        var ids = strid.split(',');
        var values = strValue.split(',');
        var disps = strDisp.split(',');
        var indexs = new Array(ids.length);
        //value
        indexs[0] = 0;
        for(var i=1;i<ids.length;i++)
        {
            try
            {
                for(var j=0;j<tr.childNodes.length;j++)
                {
                    if(tr.childNodes[j].childNodes.length >= 3 
                        && tr.childNodes[j].childNodes[1].id == ids[i])
                    {
                        indexs[i] = j;
                        break;
                    }
                }
            } 
            catch(e)
            {}
        }
        
        for(var row=0; row < meisaitable.rows.length; row++){
            tr = meisaitable.rows[row];
            if(tr.childNodes[0].childNodes[0].checked)
            {
                for(var i=1;i<ids.length;i++)
                { 
                    tr.childNodes[indexs[i]].childNodes[0].value = values[0];
                    tr.childNodes[indexs[i]].childNodes[1].value = disps[i];
                    tr.childNodes[indexs[i]].childNodes[3].value = values[i];
                }                
            }            
        }
    }
    catch(e)
    {
    }
    
    window.close();
}
 /*┗◎◎┛=====================================================================
 *
 *【画面名】
 *      POINT候補値画面
 *
 *【概要】
 *?     POINT値クリア
 *
 *      targetIds必要です、元画面ObjID
 *【変更履歴】
 *┗◎◎┛====================================================================*/
function clear_openerValue()
{
    //lang,EntityManager
    if(document.getElementById("targetIds") == null)
    {
        window.close();
        return;
    }
    else if(document.getElementById("targetIds").value == "")
    {
        window.close();
        return;
    }
    
    var strid = document.getElementById("targetIds").value;
    var ids = strid.split(',');
    
    //value
    for(var i=1;i<ids.length;i++)
    {
        try
        {
            var targetTxt = window.opener.document.getElementById(ids[i]);
            
            targetTxt.parentNode.childNodes[0].value = "";
            targetTxt.value = "";
        } 
        catch(e)
        {}
    }
    
    window.close();
}
 /*┗◎◎┛=====================================================================
 *
 *【画面名】
 *      POINT候補値画面
 *
 *【概要】
 *?     チェックされている行のPOINT値クリア
 *
 *      targetIds必要です、元画面ObjID
 *【変更履歴】
 *┗◎◎┛====================================================================*/
function clear_openerValue_all()
{
    //lang,EntityManager
    if(document.getElementById("targetIds") == null)
    {
        window.close();
        return;
    }
    else if(document.getElementById("targetIds").value == "")
    {
        window.close();
        return;
    }
    
    var meisaitable = window.opener.document.getElementById("dgmeisai");
    if(meisaitable == null) return;
    
    try
    {
        var tr = meisaitable.rows[0];
                
        var strid = document.getElementById("targetIds").value;
        var ids = strid.split(',');
        var indexs = new Array(ids.length);
        //value
        indexs[0] = 0;
        for(var i=1;i<ids.length;i++)
        {
            try
            {
                for(var j=0;j<tr.childNodes.length;j++)
                {
                    if(tr.childNodes[j].childNodes.length == 3 
                        && tr.childNodes[j].childNodes[1].id == ids[i])
                    {
                        indexs[i] = j;
                        break;
                    }
                }
            } 
            catch(e)
            {}
        }
        
        for(var row=0; row < meisaitable.rows.length; row++){
            tr = meisaitable.rows[row];
            if(tr.childNodes[0].childNodes[0].checked)
            {
                for(var i=1;i<ids.length;i++)
                { 
                    tr.childNodes[indexs[i]].childNodes[0].value = "";
                    tr.childNodes[indexs[i]].childNodes[1].value = "";
                }                
            }            
        }
    }
    catch(e)
    {
    }
    
    window.close();
}